﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Globalization;

namespace WebsiteAdmin.Wilson.ProInfo
{
    public partial class SeriesEdit : System.Web.UI.Page
    {
        public int pkid;
        public string serName;
        public string catName;
        public int catID;
        public int catValid;
        public string description;
        public string imgURL;
        public int sortBy;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                pkid = Convert.ToInt32(Request["pkid"], CultureInfo.InvariantCulture);
                DataTable dtSer = Bll.Series.Single(Global.ConnWilson, pkid);
                if (dtSer.Rows.Count == 1)
                {
                    serName = dtSer.Rows[0]["SeriesName"].ToString();
                    catID = Convert.ToInt16(dtSer.Rows[0]["CatID"]);
                    catValid = Convert.ToInt16(dtSer.Rows[0]["CatValid"]);
                    catName = dtSer.Rows[0]["CatName"].ToString();
                    description = dtSer.Rows[0]["Description"].ToString();
                    imgURL = dtSer.Rows[0]["ImgURL"].ToString();
                    sortBy = Convert.ToInt16(dtSer.Rows[0]["SortBy"], CultureInfo.InvariantCulture);

                    BindCatList();
                }
                dtSer.Dispose();
            }
        }

        protected void BindCatList()
        {
            using (DataTable dt = Bll.Category.MULTIPLE(Global.ConnWilson)) 
            {
                if (dt != null && dt.Rows.Count > 0)
                {
                    this.repCatList.DataSource = dt.DefaultView;
                    this.repCatList.DataBind();
                }
            } 
        }
    }
}
